home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / mg2a_src.zip / TERMLIB / TGETFLAG.C < prev    next >
C/C++ Source or Header  |  1988-08-23  |  2KB  |  100 lines

  1. /************************************************************************
  2.  *                                      *
  3.  *              Copyright (c) 1982, Fred Fish              *
  4.  *              All Rights Reserved                  *
  5.  *                                      *
  6.  *    This software and/or documentation is released for public          *
  7.  *    distribution for personal, non-commercial use only.          *
  8.  *    Limited rights to use, modify, and redistribute are hereby      *
  9.  *    granted for non-commercial purposes, provided that all          *
  10.  *    copyright notices remain intact and all changes are clearly     *
  11.  *    documented.  The author makes no warranty of any kind with      *
  12.  *    respect to this product and explicitly disclaims any implied    *
  13.  *    warranties of merchantability or fitness for any particular     *
  14.  *    purpose.                                  *
  15.  *                                      *
  16.  ************************************************************************
  17.  */
  18. /*
  19.  * Modified:
  20.  *    30-Apr-86 Mic Kaczmarczik
  21.  *    #define index to strchr if VAX C
  22.  *
  23.  */
  24.  
  25.  
  26.  
  27.  
  28. /*
  29.  *  LIBRARY FUNCTION
  30.  *
  31.  *    tgetflag     extract boolean termcap capability
  32.  *
  33.  *  KEY WORDS
  34.  *
  35.  *    termcap
  36.  *
  37.  *  SYNOPSIS
  38.  *
  39.  *    tgetflag(id)
  40.  *    char *id;
  41.  *
  42.  *  DESCRIPTION
  43.  *
  44.  *    Returns TRUE if specified id is present in terminal
  45.  *    entry, FALSE otherwise.
  46.  *
  47.  */
  48.  
  49. #include <stdio.h>
  50. #ifdef VAXC
  51. #define index strchr
  52. #endif
  53.  
  54. #define TRUE 1
  55. #define FALSE 0
  56.  
  57. extern char *_tcpbuf;          /* Termcap entry buffer pointer */
  58.  
  59.  
  60.  
  61. /*
  62.  *  PSEUDO CODE
  63.  *
  64.  *    Begin tgetflag
  65.  *      Initialize pointer to the termcap entry buffer.
  66.  *      While there is a field to process
  67.  *          Skip over the field separator character.
  68.  *          If this is the entry we want then
  69.  *          If entry is identifier only then
  70.  *              Return TRUE
  71.  *          Else
  72.  *              Return FALSE
  73.  *          End if
  74.  *          End if
  75.  *      End while
  76.  *      Return FALSE as default.
  77.  *    End tgetflag
  78.  *
  79.  */
  80.  
  81. tgetflag(id)
  82. char *id;
  83. {
  84.     char *bp;
  85.     extern char *index();
  86.  
  87.     bp = _tcpbuf;
  88.     while ((bp = index(bp,':')) != NULL) {
  89.       bp++;
  90.       if (*bp++ == id[0] && *bp != NULL && *bp++ == id[1]) {
  91.       if (*bp == NULL || *bp++ == ':') {
  92.           return(TRUE);
  93.       } else {
  94.           return(FALSE);
  95.       }
  96.       }
  97.     }
  98.     return(FALSE);
  99. }
  100.